<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="/pages/common/header.jsp"></jsp:include>
<title>任务检索页面</title>
<style type="text/css">
	#successRatePanelDiv td,th {
		text-align: center;
	}
	
	input.dateC{
		padding: 10px 5px 10px 5px;
		margin: 15px 1px 0px;
		border:1px solid #d0d0d0;
		box-shadow: 0 1px 2px #d0d0d0 inset,0 -1px 0 #d0d0d0 inset,0 -2px 3px #d0d0d0 inset;
		background: -webkit-linear-gradient(top,#d0d0d0,#d0d0d0);
		background: -moz-linear-gradient(top,#d0d0d0,#d0d0d0);
		background: linear-gradient(top,#d0d0d0,#d0d0d0);
		font-family: Tahoma,Arial,宋体,sans-serif;
		font-size:12px;
		font-weight:bold;
		color:#F0F0F0;
	}
	
	input.dateCActive{
		padding: 10px 5px 10px 5px;
		margin: 15px 1px 0px;
		border:1px solid #1e7db9;
		border-bottom-color:#428BCA;
		box-shadow: 0 1px 2px #428BCA inset,0 -1px 0 #428BCA inset,0 -2px 3px #428BCA inset;
		background: -webkit-linear-gradient(top,#428BCA,#428BCA);
		background: -moz-linear-gradient(top,#428BCA,#428BCA);
		background: linear-gradient(top,#428BCA,#428BCA);
		font-family: Tahoma,Arial,宋体,sans-serif;
		font-size:12px;
		font-weight:bold;
	}
</style>
<script type="text/javascript">
	$(function(){
		//日期选择按钮
		$("input[type='button']").click(function(){
			var day = $(this).attr("value");
			var navTab = $(".nav-tabs").children("li.active").first();
			var url = navTab.attr("data-target");
			if(!url || url.length<=0){
				url = window.location.href
				url = url.indexOf("?")>-1 ? url.substring(0, url.indexOf("?")) : url;
				url += "?grabDateStr="+day;
				window.location.href = url;
			}else{
				url += "?grabDateStr="+day;
				loadContent($("#content"), url);
			}
		});
		//成功数量点击事件
		$(".task-detail").click(function(){
			var chid = $(this).attr("channelId");
			var state = $(this).attr("status");
			var url = "${pageContext.request.contextPath}/pages/task/TaskDetail_detailStatusList.jsp?method=detailByChannelIdAndTaskStatus&channelId="+chid+"&taskStatus="+state +"&grabDateStr=${currentSelectDate}&authSubmit=true";
			$.layer({
			    type : 2,
			    title : '抓取统计-任务详情',
			    iframe : {src : url},
			    area : ['910px' , '500px'],
			    offset : ['100px','']
			});
		});	
	});
</script>
</head>
<body>	
<c:forEach var="o" items="${currentDates}">
	<input type="button" id="btn_${o}" value="${o}" class="${o==currentSelectDate ? 'dateCActive' : 'dateC'}"   />
</c:forEach>
<div style="background-color:#428BCA;height:20px;">说明：状态“其它”由抓取节点下领域适配器自定义，值在-5,5之外(-5至5之间的值已被任务这边占用)，大于5时代表成功，少于-5时为失败，抓取成功率=(成功数+“其它”成功数)/(任务数量-等待中-执行中)*100%。</div> 	
<div class="panel panel-default" id="successRatePanelDiv">
		<table class="table table-bordered table-hover table-striped">
			<tbody>
				<tr class="info">
					<!-- <th>抓取日期</th> -->
					<th style="text-align: center">序号</th>
					<th style="text-align: center">渠道编号</th>
					<th style="text-align: center">渠道名称</th>
					<th style="text-align: center">抓取成功率</th>
					<th style="text-align: center">任务数量</th>
					<th style="text-align: center">成功数</th>
					<th style="text-align: center">失败数</th>
					<th style="text-align: center">其它</th>
					<th style="text-align: center">执行中</th>
					<th style="text-align: center">等待中</th>
					<th style="text-align: center">流量大小 (M)</th>
					<th style="text-align: center">实际抓取量</th>
				</tr>
				<c:if test="${data == null or fn:length(data) == 0}">
					<tr>
						<td colspan="100" style="text-align: center;">没有找到符合条件的记录。</td>
					</tr>
				</c:if>
				<c:forEach var="c" items="${data}" varStatus="status">
					<tr>
						<td>${status.count}</td>
						<td>${c.channelCode }</td>
						<td>${c.channelName}</td>
						<td><font color="${c.successRate>=90 ? 'green' : (c.successRate>=80 ? 'blue' : 'red')}">
							${c.successRate}%</font></td>
						<td>${c.sum}</td>
						<td><a class="task-detail" channelId="${c.channelId}" status="3" href="javascript:void(0);">${c.successStatusCount}</a></td>
						<td><a class="task-detail" channelId="${c.channelId}" status="-2" href="javascript:void(0);">${c.fetchFailStatusCount+c.paraseFailStatusCount+c.otherFailStatusCount }</a></td>
						<td><a class="task-detail" channelId="${c.channelId}" status="-5" href="javascript:void(0);">${c.businessFailStatusCount+c.businessSuccessStatusCount }</a></td><!-- 此处还是优化    --> 
						<td><a class="task-detail" channelId="${c.channelId}" status="2" href="javascript:void(0);">${c.doingStatusCount}</a></td>
						<td><a class="task-detail" channelId="${c.channelId}" status="0" href="javascript:void(0);">${c.waitStatusCount}</td>
						<td>${c.bothMLength}</td>
						<td>${c.crawlCount}</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
	<div class="text-center panel-footer" style=""></div>
</body></html>